package main

import (
	"encoding/json"
	"io/ioutil"
	"os"
)

type Config struct {
	APIPrefix string `json:"apiPrefix,omitempty"`
	Listen    string `json:"listen,omitempty"`
	// DBConfig  DBConfig `json:"db,omitempty"`
	ShipVoyageRepoConfig ShipVoyageRepoConfig `json:"shipVoyageRepo,omitempty"`
	WharfRepoConfig      WharfRepoConfig      `json:"wharRepo,omitempty"`
}

func loadConfig(path string) (Config, error) {
	f, err := os.Open(path)
	if err != nil {
		return Config{}, err
	}
	defer f.Close() // nolint
	content, err := ioutil.ReadAll(f)
	if err != nil {
		return Config{}, err
	}
	var config Config
	err = json.Unmarshal(content, &config)
	return config, err
}
